home *** CD-ROM | disk | FTP | other *** search
- Path: news.internex.net.au!usenet
- From: sultan@connexus.apana.org.au (Jon Hornstein)
- Newsgroups: comp.lang.c++
- Subject: Re: Floating Point Error Traping by try and catch:-
- Date: Sun, 17 Mar 1996 14:29:33 GMT
- Organization: Yarra House Software Pty Ltd
- Message-ID: <4ih5bo$35d@preeda.internex.net.au>
- References: <4i836n$2u8@dfw-ixnews5.ix.netcom.com>
- NNTP-Posting-Host: dialin-10.internex.net.au
- X-Newsreader: Forte Free Agent 1.0.82
-
- Mission Impossible(?)
-
- You assignment is to get the process associated function signal
- (interrupt) to throw a c++ exception. As far as I know signals are not
- related to c++ throws. I cannot comment on tool++ class library, but
- the library implementors must grapple with the same problem. My
- feelings are that the tools library must provide as much help to find
- your coding errors as possible. In the end other tools like lint
- processing and assertion points as well as must testing must be used
- to debug these sort of errors from a system.
-
- rajash@ix.netcom.com(Rajash Gopalakrishnan ) wrote:
-
- >Hi Experts!.
-
- >We were using normal try and catch statements to trap
- >the exceptional errors occured during C++ class operation.
- >We are working on Soaris C++ 4.1 with Toolsh++ classes.
-
- >Here is a sample program which causes floating point error.
- >If anybody have a clue, please tell me a method to trap
- >this error.
-
- >BOOL Divide_By_Zero();
-
- >main()
- >{
- > try
- > {
- > Divide_By_Zero()
- > }
- > catch(long&)
- > {
- > cout << 'Got Error' << endl;
- > }
- >}
-
- >BOOL Divide_By_Zero()
- >{
- > long i,j;
-
- > i= 4.0;
-
- > j = i/0; // causing Floating Point Error
-
- > return TRUE;
- >}
-
- >Here what I found is that before catch, arithemetic experssion fault
- >occurs and core is dumping. One method I found is to redirect the
- >signal
- >handler and do a catch but that's a round about method. Can anybody
- >explain how we can handle this situation by try and catch alone. Is
- >there
- >any method to show where error occured and line#.
-
- >Thanks
- >Raj
-
-
-
-